<template>
  <div v-if="isAdmin">
    <Admins/>
  </div>
  <div v-else-if="application">
    <Applications/>
  </div>
  <div v-else-if="hr">
    <HR/>
  </div>
  <div v-else-if="company">
    <Company/>
  </div>
  <div v-else></div>
</template>

<script>
import { role } from '@/api/echarts/echart';
import Applications from '@/views/applications';
import Admins from '@/views/admins';
import HR from '@/views/HR';
import Company from '@/views/company';

export default {
  components: {
    Applications,
    Admins,
    HR,
    Company, // 注册新增的组件
  },
  data() {
    return {
      isAdmin: false,
      application: false,
      hr: false,
      company: false, // 新增的 company 状态
    };
  },
  async mounted() {
    await this.isAuthorized();
  },
  methods: {
    isAuthorized() {
      role().then((res) => {
        let roles = res.data.role;
        console.log(roles);
        if (roles == "管理员") {
          this.isAdmin = true;
        } else if (roles == "应聘者") {
          this.application = true;
        } else if (roles == "面试官") {
          this.hr = true;
        } else if (roles == "公司") {
          this.company = true;
        }
      });
    },
  },
};
</script>


